home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug191 / demo.c < prev    next >
Text File  |  1986-05-27  |  4KB  |  145 lines

  1. /*#title DEMO.C    05/26/86 */
  2. /****************************************************************
  3. *****************************************************************
  4. **                                                             **
  5. **      file: DEMO.C                                           **
  6. **                                                             **
  7. **      function:   Demonstrate W_FORM and W_CHATTR functions  **
  8. **                                                             **
  9. **      programmer: GVWoodley                                  **
  10. **                                                             **
  11. *****************************************************************
  12. *****************************************************************
  13. */
  14.  
  15. #include "STD.H"
  16. #include "C_WDEF.H"
  17.  
  18. #define    BEEPDEL        1000        /* beep delay */
  19. #define LINE_LEN    31            /* line length */
  20.  
  21. extern char err_exit,    /* set to TRUE to return to dos on error */
  22.             extend;        /* TRUE if extended char typed */
  23.  
  24. char        win_bg,        /* window background */
  25.             bor_fg,        /* border foreground */
  26.             bor_bg,        /* border background */
  27.             text_fg,    /* text foreground */
  28.             text_bg,    /* text background */
  29.             get_fg;        /* color of text input by w_getstr() */
  30. int            line_menu;
  31. WORD        main_stop[7 * 2 + 1];    /* total of 7 stops */
  32. /*#eject    */
  33. /****************************************************************
  34.     MAIN-LINE - Open LINE_MENU window,
  35.                 type a prompt message,
  36.                 get operator response,
  37.                 close window.
  38. ****************************************************************/
  39. char main_line (msg_ptr)
  40. char    *msg_ptr;                    /* pointer to prompt message */
  41. {
  42.     char    cc;                        /* console char */
  43.     int        status;
  44.  
  45.     status = w_open (
  46.                 line_menu,
  47.                 main_stop[12], main_stop[13],    
  48.                                  /* upper left-hand coords */
  49.                 CLR,            /* clear window */
  50.                 win_bg,         /* window background */
  51.                 SNGL_LN,        /* border type */
  52.                 bor_fg, bor_bg);/* border colors */
  53.     status = w_gotoxy (1, 0);
  54.     w_write (msg_ptr);
  55.  
  56.     cc = toupper(keyin());
  57.     w_close();                        /* close line_menu window */
  58.  
  59.     return (cc);
  60.     }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. /****************************************************************
  68.     MAIN PROGRAM
  69. ****************************************************************/
  70. main (argc, argv)
  71.  
  72. WORD    argc;            /* count of arguments */
  73. char    **argv;            /* pointer to argument pointers */
  74.  
  75. {
  76.     BYTE    cc;            /* console char */
  77.     BOOLEAN    success,    /* general-purpose success */
  78.             done;        /* done with program */
  79.     int        status,        /* status of window functions */
  80.             main_menu;
  81.     WORD    base,        /* base index */
  82.             old_base;
  83. /*#eject    */
  84. /* initialize */
  85.     old_base = 0;
  86.     win_bg = NORM;
  87.     bor_bg = NORM;
  88.     bor_fg = REVERS;
  89.     text_fg = NORM | BRIGHT;
  90.     text_bg = REVERS;
  91.     get_fg = REVERS | BRIGHT;
  92.  
  93.     w_init();                    /* init C_WINDOW package */
  94. /* define our windows */
  95.     main_menu = w_def (78, 23, NOBORDER);
  96.     line_menu = w_def (39, 3, BORDER);
  97.  
  98.     status = w_open (
  99.                 main_menu, 1, 1,    /* upper left-hand coords */
  100.                 CLR,                /* clear window the 1st time */
  101.                 win_bg,             /* window background */
  102.                 XX,                    /* border type */
  103.                 XX, XX);            /* border colors */
  104.     status = w_form (
  105.                 0, 0,
  106.                 "demo.frm",            /* form name */
  107.                 8,                    /* tab interval */
  108.                 main_stop);            /* stop table ptr */
  109. /*#eject */    
  110. /****************************************************************
  111.     MAIN LOOP
  112. ****************************************************************/
  113.     done = FALSE;
  114.     while (!done)  {
  115. /* mainmenu is being displayed */
  116.         status = w_gotoxy (main_stop[12], main_stop[13]);
  117.         cc = toupper(keyin());
  118.  
  119. /* here for selections 1 - 6 */
  120.         base = (cc - '1') * 2;
  121.         if (base <= 10)  {
  122.     /* display the old line in normal video */
  123.             w_chattr (main_stop[old_base], main_stop[old_base + 1],
  124.                 bor_bg, LINE_LEN);
  125.     /* display the new line in reverse video */
  126.             w_chattr (main_stop[base], main_stop[base + 1],
  127.                 text_bg, LINE_LEN);
  128.             old_base = base;            /* update for next time */
  129.             }
  130.  
  131. /* here if selection = X */
  132.         else if (cc == 'X')  {
  133.             if (main_line ("Are you sure? ") == 'Y') 
  134.                 done = TRUE;
  135.             }
  136.  
  137. /* illegal selection */
  138.         else
  139.             beep (BEEPDEL);
  140.         }
  141. /* clean up & leave */
  142.     w_close();
  143.     exit (0);        /* normal exit */
  144.     }
  145.